import 'dart:convert' show json;

T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }

  return null;
}

class ThirdPartBean {
  ThirdPartBean({
    this.code,
    this.data,
  });

  factory ThirdPartBean.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : ThirdPartBean(
    code: asT<int>(jsonRes['code']),
    data: Data.fromJson(asT<Map<String, dynamic>>(jsonRes['data'])),
  );

  int code;
  Data data;

  Map<String, dynamic> toJson() => <String, dynamic>{
    'code': code,
    'data': data,
  };
  @override
  String toString() {
    return json.encode(this);
  }
}

class Data {
  Data({
    this.platform,
    this.openid,
    this.has_reg
  });

  factory Data.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : Data(
    platform: asT<String>(jsonRes['platform']),
      openid: asT<String>(jsonRes['openid']),
      has_reg: asT<bool>(jsonRes['has_reg']),
  );

  String platform;
  String openid;
  bool has_reg;

  Map<String, dynamic> toJson() => <String, dynamic>{
    'platform': platform,
    'openid': openid,
    'has_reg': has_reg
  };
  @override
  String toString() {
    return json.encode(this);
  }
}
